// Email.h: interface for the CEmail class.
//
//////////////////////////////////////////////////////////////////////

#ifndef _SEMAILLIB_EMAIL_H
#define _SEMAILLIB_EMAIL_H

#include <vector>
#include <string>

extern std::string trim(std::string& s,const std::string& drop = " ");
extern std::string trimspace(std::string& s);

class CEmail  
{
public:
	
	enum ToType{ TO, CC, BCC };

	class To
	{
	public:
		std::string	alias;
		std::string	addr;
		ToType	type;
		
		bool IsEmpty()
		{
			return addr.empty();
		}
	};

	class From
	{
	public:
		std::string	alias;
		std::string	addr;
		
		bool IsEmpty()
		{
			return addr.empty();
		}
	};

	CEmail::From GetFrom();
	To GetFirstTo();
	To GetCurTo();
	To GetNextTo();
	std::string GetHeader();
	virtual std::string GetContent();
	virtual void GetData(std::string& data);

	void AddTo(const std::string& alias, const std::string& addr, ToType type = TO);
	void AddCc(const std::string& alias, const std::string& addr);
	void AddBcc(const std::string& alias, const std::string& addr);
	void SetContent(const std::string& txt);
	void SetSubject(const std::string& subject);
	void SetBcc(const std::string& bcc);
	void SetCc(const std::string& cc);
	void SetTo(const std::string& to, ToType type = TO);
	void SetFrom(const std::string& alias, const std::string& addr);
	void SetFrom(const std::string& from);
	void SetHeader(const std::string &header);
	CEmail();
	virtual ~CEmail();
	
protected:
	virtual void GenerateHeader();

	From	m_From;

	std::vector<To> m_vToList;
	unsigned int m_nCurTo;

	std::string m_strSubject;
	std::string	m_strContent;

	std::string	m_strHeader;

};

#endif

